package net.worldscale.xp.wslib.urm.loader;

import java.io.InputStream;

public abstract class Loader {

	private static final int PHASE_BASE = 1000;

	public static final int PHASE_INIT = PHASE_BASE + 0;
	public static final int PHASE_LOADING = PHASE_BASE + 1;

	public static final int PHASE_FINISH = PHASE_BASE + 10;

	public static final int PHASE_COMPLETE = PHASE_BASE + 20;
	public static final int PHASE_BAD_SCHEME = PHASE_BASE + 23;
	public static final int PHASE_RETRY_TIMEOUT = PHASE_BASE + 24;
	public static final int PHASE_NO_LISTENER = PHASE_BASE + 25;
	public static final int PHASE_NO_ACCEPT_MIME = PHASE_BASE + 26;

	public abstract String getURI();

	public abstract String getOriginURI();

	public abstract String getFinalURI();

	public abstract void loadAsync();

	public abstract void loadSync();

	public abstract void cancel();

	public abstract void setListener(ILoaderListener l);

	public abstract String getMimeType();

	public abstract long getTotalLength();

	public abstract long getLoadedLength();

	public abstract int getResponseCode();

	public abstract int getPhase();

	public abstract InputStream openInputStream();

	public static Loader newInstance(String uri) {
		return new ImplDefaultLoader(uri);
	}

}
